<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Supports\LinkedIn\Client;
use App\Models\User;

class ExecLinkedData extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'cc:exec-linkedin';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $client = new Client(
            getenv('LINKDIN_CLIENT_ID'),
            getenv('LINKDIN_CLIENT_SECRET'),
        );
        $client->setRedirectUrl('https://www.xbreakingtechinsight.com');

        $user = User::find(1);
        
        $client->setAccessToken($user->linkdin_token);

        $arr = [ 
            'q'=>"organizationalEntity",
            'organizationalEntity' => 'urn:li:organization:100897090',
        ];
        $res = $client->get(                 
                        'organizationalEntityShareStatistics',                         
                        $arr
                    );
        dd($res);
    }
}
